﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;
using DTO;
using BLL;
using System.Diagnostics;
using System.IO;

namespace TwoChromo
{
    public class MainClass
    {
        private void geneticAlgorithm(string[] args)
        {          
            if ((args == null) || (args.Length == 0))
            {
                Console.WriteLine("Khong co tham so");
            }
            else
            {
                //GA: giai_thuat(0); ten_file_du_lieu(1); so_lan_danh_gia(2); ti_le_lai_ghep(3); kich_thuoc_quan_the_ban_dau(4); tourament_size(5); elitis(6); seed(7);
                Console.WriteLine("* File du lieu: " + args[1]);                
                CityObject[] citiesCoordinate;
                int numCity;
                ReadWriteFile ioFile = new ReadWriteFile();
                ioFile.readFile(args[1], out citiesCoordinate,out numCity);
                GA algo; //= new GA(numCity, int.Parse(args[2]), float.Parse(args[3]), int.Parse(args[4]), int.Parse(args[5]), Convert.ToBoolean(args[6]), int.Parse(args[7]));
            
                
                string saveFile = "";
                string tempPath = "";
            
                PathTour bestPathTour = new PathTour(numCity);
                bestPathTour.Fitness = double.MaxValue;

                Stopwatch stGA = new Stopwatch();               
                switch (Convert.ToInt32(args[0]))
                {                   
                    case 1:
                        #region GA_MSCX
                         algo = new GA(numCity, int.Parse(args[2]), float.Parse(args[3]), int.Parse(args[4]), int.Parse(args[5]), Convert.ToBoolean(args[6]), int.Parse(args[7]));
                        tempPath = "GA_MSCX_" + args[1] + "_evaluate(" + args[2] + ")_crossRate(" + args[3] + ")_popSize(" + args[4] + ")_touranmentSize(" + args[5] + ")_seed(" + args[7] + ")";
                        saveFile = tempPath + @".info";
                        Console.WriteLine("** GA_MSCX_" + "seed(" + args[7] + ")");
                        stGA.Start();
                        algo.GA_MSCX(ref bestPathTour, citiesCoordinate, saveFile);
                        stGA.Stop();
                        saveFile = tempPath + @"_Final.tour";
                        ioFile.writeTourToFile(saveFile, args[7], bestPathTour.OrderCity, numCity, bestPathTour.Fitness, stGA);
                        bestPathTour = null;
                        break;
                        #endregion
                       
                    case 2:
                        #region GA_OX
                        //GA: giai_thuat(0); ten_file_du_lieu(1); so_lan_danh_gia(2); ti_le_lai_ghep(3); kich_thuoc_quan_the(4); tourament_size(5); elitis(6); seed(7);percentApplyVNSLocalsearch(8)
                        algo = new GA(numCity, int.Parse(args[2]), float.Parse(args[3]), int.Parse(args[4]), int.Parse(args[5]), Convert.ToBoolean(args[6]), int.Parse(args[7]), int.Parse(args[8]));
                        tempPath = "GA_OX_" + args[1] + "_evaluate(" + args[2] + ")_crossRate(" + args[3] + ")_popSize(" + args[4] + ")_touranmentSize(" + args[5] + ")_seed(" + args[7] + ")";
                        saveFile = tempPath + @".info";
                        Console.WriteLine("** GA_OX_" + "seed(" + args[7] + ")");
                        stGA.Start();
                        algo.GA_OX(ref bestPathTour, citiesCoordinate, saveFile);
                        stGA.Stop();
                        saveFile = tempPath + @"_Final.tour";
                        ioFile.writeTourToFile(saveFile, args[7], bestPathTour.OrderCity, numCity, bestPathTour.Fitness, stGA);
                        bestPathTour = null;
                        break;
                        #endregion
                    case 3:
                        //GA use OX Crossover and VNS local search
                        //GA: giai_thuat(0); ten_file_du_lieu(1); so_lan_danh_gia(2); ti_le_lai_ghep(3); kich_thuoc_quan_the(4); tourament_size(5); elitis(6); seed(7); percentApplyVNSLocalsearch(8)
                        algo = new GA(numCity, int.Parse(args[2]), float.Parse(args[3]), int.Parse(args[4]), int.Parse(args[5]), Convert.ToBoolean(args[6]), int.Parse(args[7]), int.Parse(args[8]));
                        tempPath = "GA_OX_VNS_2Opt_" + args[1] + "_evaluate(" + args[2] + ")_crossRate(" + args[3] + ")_popSize(" + args[4] + ")_touranmentSize(" + args[5] + ")_seed(" + args[7] + ")_perApplVNS(" + args[8] + ")";
                        saveFile = tempPath + @".info";
                        Console.WriteLine("** GA_OX_VNS_2Opt_: " + "seed(" + args[7] + ")_perApplVNS(" + args[8] + ")");
                        stGA.Start();
                        algo.GA_OX_VNS_2Opt(ref bestPathTour, citiesCoordinate, saveFile);
                        stGA.Stop();
                        saveFile = tempPath + @"_Final.tour";
                        ioFile.writeTourToFile(saveFile, args[7], bestPathTour.OrderCity, numCity, bestPathTour.Fitness, stGA);
                        bestPathTour = null;
                        break;
                    case 4:
                        //GA use OX Crossover and VNS local search (Swap neighborhood)
                        //GA: giai_thuat(0); ten_file_du_lieu(1); so_lan_danh_gia(2); ti_le_lai_ghep(3); kich_thuoc_quan_the(4); tourament_size(5); elitis(6); seed(7); percentApplyVNSLocalsearch(8)
                        algo = new GA(numCity, int.Parse(args[2]), float.Parse(args[3]), int.Parse(args[4]), int.Parse(args[5]), Convert.ToBoolean(args[6]), int.Parse(args[7]), int.Parse(args[8]));
                        tempPath = "GA_OX_VNS_SwapNeighborhood_" + args[1] + "_evaluate(" + args[2] + ")_crossRate(" + args[3] + ")_popSize(" + args[4] + ")_touranmentSize(" + args[5] + ")_seed(" + args[7] + ")_perApplVNS(" + args[8] + ")";
                        saveFile = tempPath + @".info";
                        Console.WriteLine("** GA_OX_VNS_SwapNeighborhood_: " + "seed(" + args[7] + ")_perApplVNS(" + args[8] + ")");
                        stGA.Start();
                        algo.GA_OX_VNS_Swap(ref bestPathTour, citiesCoordinate, saveFile);
                        stGA.Stop();
                        saveFile = tempPath + @"_Final.tour";
                        ioFile.writeTourToFile(saveFile, args[7], bestPathTour.OrderCity, numCity, bestPathTour.Fitness, stGA);
                        bestPathTour = null;
                        break;

                                           
                    case 5:
                        #region GA_OX_VNS_SwapInSegment
                        /********************************************************************************/
                        /* Chia Tour lam m=kmax=ncity/10 doan                                           */
                        /* Nk duoc thuc hien boi doi vi tri 2 thanh pho ke nhau trong cac doan tu 1..k  */
                        /********************************************************************************/
                        //GA: giai_thuat(0); ten_file_du_lieu(1); so_lan_danh_gia(2); ti_le_lai_ghep(3); kich_thuoc_quan_the(4); tourament_size(5); elitis(6); seed(7); percentApplyVNSLocalsearch(8); numSegment(9);
                        algo = new GA(numCity, int.Parse(args[2]), float.Parse(args[3]), int.Parse(args[4]), int.Parse(args[5]), Convert.ToBoolean(args[6]), int.Parse(args[7]), int.Parse(args[8]));
                        tempPath = "GA_OX_VNS_SwapInSegment_" + args[1] + "_evaluate(" + args[2] + ")_crossRate(" + args[3] + ")_popSize(" + args[4] + ")_touranmentSize(" + args[5] + ")_seed(" + args[7] + ")_perApplVNS(" + args[8] + ")_numSgm(" + args[9] + ")";
                        saveFile = tempPath + @".info";
                        Console.WriteLine("** GA_OX_VNS_SwapInSegment: " + "seed(" + args[7] + ")_perApplVNS(" + args[8] + ")_numSgm(" + args[9] + ")");
                        stGA.Start();
                        algo.GA_OX_VNS_SwapInSegment(ref bestPathTour, citiesCoordinate, saveFile, int.Parse(args[9]));
                        stGA.Stop();
                        saveFile = tempPath + @"_Final.tour";
                        ioFile.writeTourToFile(saveFile, args[7], bestPathTour.OrderCity, numCity, bestPathTour.Fitness, stGA);
                        bestPathTour = null;
                        break;
                        #endregion
                      
                    case 6:
                        #region GA_OX_VNS_Segment
                        /********************************************************************************/
                        /* Chia Tour lam m=kmax=ncity/10 doan                                           */
                        /* Nk duoc thuc hien boi doi vi tri 2 thanh pho ke nhau trong cac doan tu 1..k  */
                        /********************************************************************************/
                        //GA: giai_thuat(0); ten_file_du_lieu(1); so_lan_danh_gia(2); ti_le_lai_ghep(3); kich_thuoc_quan_the(4); tourament_size(5); elitis(6); seed(7);percentApplyVNSLocalsearch(8); numSegment(9);
                        algo = new GA(numCity, int.Parse(args[2]), float.Parse(args[3]), int.Parse(args[4]), int.Parse(args[5]), Convert.ToBoolean(args[6]), int.Parse(args[7]), int.Parse(args[8]));
                        tempPath = "GA_OX_VNS_Segment_" + args[1] + "_evaluate(" + args[2] + ")_crossRate(" + args[3] + ")_popSize(" + args[4] + ")_touranmentSize(" + args[5] + ")_seed(" + args[7] + ")_perApplVNS(" + args[8] + ")_numSgm(" + args[9] + ")";
                        saveFile = tempPath + @".info";
                        Console.WriteLine("** GA_OX_VNS_Segment: " + "seed(" + args[7] + ")_perApplVNS(" + args[8] + ")_numSgm(" + args[9] + ")");
                        stGA.Start();
                        algo.GA_OX_VNS_Segment(ref bestPathTour, citiesCoordinate, saveFile, int.Parse(args[9]));
                        stGA.Stop();
                        saveFile = tempPath + @"_Final.tour";
                        ioFile.writeTourToFile(saveFile, args[7], bestPathTour.OrderCity, numCity, bestPathTour.Fitness, stGA);
                        bestPathTour = null;
                        break;
                        #endregion

                    case 7:
                        #region GA_OX_VNS_SwapSegment
                        /****************************************************************************/
                        /* Chia Tour lam m=kmax=ncity/10 doan                                       */
                        /* Nk duoc thuc hien boi: dao k lan vi tri cua 2 doan (segment)             */
                        /****************************************************************************/
                        //GA: giai_thuat(0); ten_file_du_lieu(1); so_lan_danh_gia(2); ti_le_lai_ghep(3); kich_thuoc_quan_the(4); tourament_size(5); elitis(6); seed(7);percentApplyVNSLocalsearch(8); numSegment(9);
                        algo = new GA(numCity, int.Parse(args[2]), float.Parse(args[3]), int.Parse(args[4]), int.Parse(args[5]), Convert.ToBoolean(args[6]), int.Parse(args[7]), int.Parse(args[8]));
                        tempPath = "GA_OX_VNS_SwapSegment_" + args[1] + "_evaluate(" + args[2] + ")_crossRate(" + args[3] + ")_popSize(" + args[4] + ")_touranmentSize(" + args[5] + ")_seed(" + args[7] + ")_perApplVNS(" + args[8] + ")_numSgm(" + args[9] + ")";
                        saveFile = tempPath + @".info";
                        Console.WriteLine("** GA_OX_VNS_SwapSegment: " + "seed(" + args[7] + ")_perApplVNS(" + args[8] + ")_numSgm(" + args[9] + ")");
                        stGA.Start();
                        algo.GA_OX_VNS_SwapSegment(ref bestPathTour, citiesCoordinate, saveFile, int.Parse(args[9]));
                        stGA.Stop();
                        saveFile = tempPath + @"_Final.tour";
                        ioFile.writeTourToFile(saveFile, args[7], bestPathTour.OrderCity, numCity, bestPathTour.Fitness, stGA);
                        bestPathTour = null;
                        break;
                        #endregion

                    case 8:
                        #region GA_OX_VNS_CombineSwapAndMoveSegment
                        /****************************************************************************************************************/
                        /* Chia Tour lam m=kmax=ncity/10 doan                                                                           */
                        /* Nk duoc thuc hien boi: dao k lan vi tri cua 2 doan (segment) va trong moi doan se dao lon vi tri ca phan tu  */
                        /****************************************************************************************************************/
                        //GA: giai_thuat(0); ten_file_du_lieu(1); so_lan_danh_gia(2); ti_le_lai_ghep(3); kich_thuoc_quan_the(4); tourament_size(5); elitis(6); seed(7);percentApplyVNSLocalsearch(8); numSegment(9);
                        algo = new GA(numCity, int.Parse(args[2]), float.Parse(args[3]), int.Parse(args[4]), int.Parse(args[5]), Convert.ToBoolean(args[6]), int.Parse(args[7]), int.Parse(args[8]));
                        tempPath = "GA_OX_VNS_CombineSwapAndMoveSegment_" + args[1] + "_evaluate(" + args[2] + ")_crossRate(" + args[3] + ")_popSize(" + args[4] + ")_touranmentSize(" + args[5] + ")_seed(" + args[7] + ")_perApplVNS(" + args[8] + ")_numSgm(" + args[9] + ")";
                        saveFile = tempPath + @".info";
                        Console.WriteLine("** GA_OX_VNS_CombineSwapAndMoveSegment_: " + "seed(" + args[7] + ")_perApplVNS(" + args[8] + ")_numSgm(" + args[9] + ")");
                        stGA.Start();
                        algo.GA_OX_VNS_CombineSwapAndMoveSegment(ref bestPathTour, citiesCoordinate, saveFile, int.Parse(args[9]));
                        stGA.Stop();
                        saveFile = tempPath + @"_Final.tour";
                        ioFile.writeTourToFile(saveFile, args[7], bestPathTour.OrderCity, numCity, bestPathTour.Fitness, stGA);
                        bestPathTour = null;
                        break;
                        #endregion
                    
                    case 9:
                        #region swapNextCity
                        /****************************************************************************/
                        /*                                                                          */
                        /* Nk duoc thuc hien boi: dao k lan 2 thanh pho ke nhau                     */
                        /****************************************************************************/
                        //GA: giai_thuat(0); ten_file_du_lieu(1); so_lan_danh_gia(2); ti_le_lai_ghep(3); kich_thuoc_quan_the(4); tourament_size(5); elitis(6); seed(7);percentApplyVNSLocalsearch(8);
                        algo = new GA(numCity, int.Parse(args[2]), float.Parse(args[3]), int.Parse(args[4]), int.Parse(args[5]), Convert.ToBoolean(args[6]), int.Parse(args[7]), int.Parse(args[8]));
                        tempPath = "GA_OX_VNS_SwapNextCity_" + args[1] + "_evaluate(" + args[2] + ")_crossRate(" + args[3] + ")_popSize(" + args[4] + ")_touranmentSize(" + args[5] + ")_seed(" + args[7] + ")_perApplVNS(" + args[8] + ")";
                        saveFile = tempPath + @".info";
                        Console.WriteLine("** GA_OX_VNS_SwapNextCity: " + "seed(" + args[7] + ")_perApplVNS(" + args[8] + ")");
                        stGA.Start();
                        algo.GA_OX_VNS_SwapNextCity(ref bestPathTour, citiesCoordinate, saveFile);
                        stGA.Stop();
                        saveFile = tempPath + @"_Final.tour";
                        ioFile.writeTourToFile(saveFile, args[7], bestPathTour.OrderCity, numCity, bestPathTour.Fitness, stGA);
                        bestPathTour = null;
                        break;

                    #endregion

                    case 10:
                        #region ApplyVNSForBestTours
                        /****************************************************************************/
                        /* Ap dung VNS cho p% ca the tot nhat                                       */
                        /* Nk duoc thuc hien boi: dao k lan 2 thanh pho ke nhau                     */
                        /****************************************************************************/
                        //GA: giai_thuat(0); ten_file_du_lieu(1); so_lan_danh_gia(2); ti_le_lai_ghep(3); kich_thuoc_quan_the(4); tourament_size(5); elitis(6); seed(7);percentApplyVNSLocalsearch(8);
                        algo = new GA(numCity, int.Parse(args[2]), float.Parse(args[3]), int.Parse(args[4]), int.Parse(args[5]), Convert.ToBoolean(args[6]), int.Parse(args[7]), int.Parse(args[8]));
                        tempPath = "GA_OX_VNS_ApplyVNSForBestTours_" + args[1] + "_evaluate(" + args[2] + ")_crossRate(" + args[3] + ")_popSize(" + args[4] + ")_touranmentSize(" + args[5] + ")_seed(" + args[7] + ")_perApplVNS(" + args[8] + ")";
                        saveFile = tempPath + @".info";
                        Console.WriteLine("** GA_OX_VNS_ApplyVNSForBestTours: " + "seed(" + args[7] + ")_perApplVNS(" + args[8] + ")");
                        stGA.Start();
                        algo.GA_OX_VNS_applyVNSForBestTours(ref bestPathTour, citiesCoordinate, saveFile);
                        stGA.Stop();
                        saveFile = tempPath + @"_Final.tour";
                        ioFile.writeTourToFile(saveFile, args[7], bestPathTour.OrderCity, numCity, bestPathTour.Fitness, stGA);
                        bestPathTour = null;
                        break;

                        #endregion

                    case 11:
                        #region ChangeVNS
                        /**********************************************************************************************************/
                        /* Sau mot so lan danh gia ma fitness cua ca the tot nhat khong thay doi thi chuyen sang su dung VNS khac */
                        /* Su dung VNS: swapNextCity & swapSegment + swapInSegment                                                */
                        /**********************************************************************************************************/
                        //GA: giai_thuat(0); ten_file_du_lieu(1); so_lan_danh_gia(2); ti_le_lai_ghep(3); kich_thuoc_quan_the(4); tourament_size(5); elitis(6); seed(7); percentApplyVNSLocalsearch(8);
                        //percentAppVNS1(9); percentAppVNS1(10); percentChangeVNS(11); numSgm(12)
                        algo = new GA(numCity, int.Parse(args[2]), float.Parse(args[3]), int.Parse(args[4]), int.Parse(args[5]), Convert.ToBoolean(args[6]), int.Parse(args[7]), int.Parse(args[8]));
                        tempPath = "GA_OX_ChangeVNS_" + args[1] + "_eval(" + args[2] + ")_crRate(" + args[3] + ")_pSize(" + args[4] 
                            + ")_seed(" + args[7] + ")_perApplVNS(" + args[8] + ")_perApplVNS1(" + args[9] + ")_perApplVNS2(" + args[10] + ")_perChangeVNS(" + args[11]
                            + ")_numSgm(" + args[12] + ")";
                        saveFile = tempPath + @".info";
                        Console.WriteLine("** GA_OX_ChangeVNS: " + "seed(" + args[7] + ")_perApplVNS(" + args[8] + ")_perApplVNS1(" + args[9] + ")_perApplVNS2(" + args[10] + ")_perChangeVNS(" + args[11]
                            + ")_numSgm(" + args[12] + ")");
                        stGA.Start();
                        algo.GA_OX_ChangeVNS(ref bestPathTour, citiesCoordinate, saveFile, int.Parse(args[9]), int.Parse(args[10]), int.Parse(args[11]), int.Parse(args[12]));
                        stGA.Stop();
                        saveFile = tempPath + @"_Final.tour";
                        ioFile.writeTourToFile(saveFile, args[7], bestPathTour.OrderCity, numCity, bestPathTour.Fitness, stGA);
                        bestPathTour = null;
                        break;

                        #endregion
























                    //demo Variable Neighborhood Search use OX crossover and 2-opt neighborhood
                    case 20:
                    #region Thu tham so cu the
                        VariableNeighborHoodSearch vnsDemo = new VariableNeighborHoodSearch();
                        PathTour ch = new PathTour(numCity);
                        InitChromo initChromo = new InitChromo();
                        Random ran = new Random(1);
                        initChromo.createPathTour(ref ch, numCity, ran);
                        Evaluate eval = new Evaluate();
                        ch.Fitness = eval.calCostOfTour(ch.OrderCity, numCity, citiesCoordinate);
                        ////PathTour optTour = vnsDemo.VNS_Kth_Random_Neighborhood(ch, citiesCoordinate, ran);
                        //int[] optTour = vnsDemo.randomSegmentNeighborhood(ch, 4, ran);
                        ////optTour = vnsDemo.VNS(ch, citiesCoordinate);

                        vnsDemo.swapSegment(ch, 5, 3, ran);
                        Console.ReadLine();
                        break;
                    #endregion
                    



























                    //Giai thuat VNS khong su dung GA
                    case 21:
                        #region VNS_Algorithm_2opt
                        //GA: giai_thuat(0); ten_file_du_lieu(1); so_lan_danh_gia(2); seed(3)
                        algo = new GA(numCity, int.Parse(args[2]), int.Parse(args[3]));
                        tempPath = "VNS_Algorithm_" + args[1] + "_evaluate(" + args[2] + ")_seed(" + args[3] + ")";
                        saveFile = tempPath + @".info";
                        Console.WriteLine("** VNS_Algorithm_: " + "seed(" + args[3] + ")");
                        stGA.Start();
                        algo.VNS_Algorithm(numCity, ref bestPathTour, citiesCoordinate);
                        stGA.Stop();
                        saveFile = tempPath + @"_Final.tour";
                        ioFile.writeTourToFile(saveFile, args[3], bestPathTour.OrderCity, numCity, bestPathTour.Fitness, stGA);
                        bestPathTour = null;
                        break;             
                        #endregion                        
                    case 22:
                        #region VNS_Algorithm_SwapInSegment
                        //GA: giai_thuat(0); ten_file_du_lieu(1); so_lan_danh_gia(2); seed(3); numSegment(4);
                        algo = new GA(numCity, int.Parse(args[2]), int.Parse(args[3]));
                        tempPath = "VNS_Alg_SwapInSegment_" + args[1] + "_evaluate(" + args[2] + ")_seed(" + args[3] + ")";
                        saveFile = tempPath + @".info";
                        Console.WriteLine("** VNS_Alg_SwapInSegment_: " + "seed(" + args[3] + ")");
                        stGA.Start();
                        algo.VNS_Alg_SwapInSegment(numCity, ref bestPathTour, citiesCoordinate, int.Parse(args[4]));
                        stGA.Stop();
                        saveFile = tempPath + @"_Final.tour";
                        ioFile.writeTourToFile(saveFile, args[3], bestPathTour.OrderCity, numCity, bestPathTour.Fitness, stGA);
                        bestPathTour = null;
                        break;
                        #endregion
                    case 23:
                        #region VNS_Algorithm_Segment
                        //GA: giai_thuat(0); ten_file_du_lieu(1); so_lan_danh_gia(2); seed(3); numSegment(4);
                        algo = new GA(numCity, int.Parse(args[2]), int.Parse(args[3]));
                        tempPath = "VNS_Alg_Segment_" + args[1] + "_evaluate(" + args[2] + ")_seed(" + args[3] + ")";
                        saveFile = tempPath + @".info";
                        Console.WriteLine("** VNS_Alg_Segment_: " + "seed(" + args[3] + ")");
                        stGA.Start();
                        algo.VNS_Alg_InSegment(numCity, ref bestPathTour, citiesCoordinate, int.Parse(args[4]));
                        stGA.Stop();
                        saveFile = tempPath + @"_Final.tour";
                        ioFile.writeTourToFile(saveFile, args[3], bestPathTour.OrderCity, numCity, bestPathTour.Fitness, stGA);
                        bestPathTour = null;
                        break;
                        #endregion
                    case 24:
                        #region VNS_Algorithm_SwapSegment
                        //GA: giai_thuat(0); ten_file_du_lieu(1); so_lan_danh_gia(2); seed(3); numSegment(4);
                        algo = new GA(numCity, int.Parse(args[2]), int.Parse(args[3]));
                        tempPath = "VNS_Alg_SwapSegment_" + args[1] + "_evaluate(" + args[2] + ")_seed(" + args[3] + ")_numSgm(" + args[4] + ")";
                        saveFile = tempPath + @".info";
                        Console.WriteLine("** VNS_Alg_SwapSegment_: " + "seed(" + args[3] + ")_numSgm(" + args[4] + ")");
                        stGA.Start();
                        algo.VNS_Alg_SwapSegment(numCity, ref bestPathTour, citiesCoordinate, int.Parse(args[4]));
                        stGA.Stop();
                        saveFile = tempPath + @"_Final.tour";
                        ioFile.writeTourToFile(saveFile, args[3], bestPathTour.OrderCity, numCity, bestPathTour.Fitness, stGA);
                        bestPathTour = null;
                        break;
                        #endregion
                    case 25:
                        #region VNS_Algorithm_SwapSegment + SwapInSegment
                        //GA: giai_thuat(0); ten_file_du_lieu(1); so_lan_danh_gia(2); seed(3); numSegment(4);
                        algo = new GA(numCity, int.Parse(args[2]), int.Parse(args[3]));
                        tempPath = "VNS_Alg_CombineSwapAndMoveSegment_" + args[1] + "_evaluate(" + args[2] + ")_seed(" + args[3] + ")_numSgm(" + args[4] + ")";
                        saveFile = tempPath + @".info";
                        Console.WriteLine("** CombineSwapAndMoveSegment: " + "seed(" + args[3] + ")_numSgm(" + args[4] + ")");
                        stGA.Start();
                        algo.VNS_Alg_CombineSwapAndMoveSegment(numCity, ref bestPathTour, citiesCoordinate, int.Parse(args[4]));
                        stGA.Stop();
                        saveFile = tempPath + @"_Final.tour";
                        ioFile.writeTourToFile(saveFile, args[3], bestPathTour.OrderCity, numCity, bestPathTour.Fitness, stGA);
                        bestPathTour = null;
                        break;
                        #endregion


                       


                }
              
                Console.WriteLine("\t + Thoi gian chay: {0} giay", stGA.Elapsed.ToString());
                Console.WriteLine("\t + OK");
            }
        }

        public void run(string[] args)
        {
            Console.WriteLine("-----------START-----------");
            geneticAlgorithm(args);

            Console.WriteLine("-----------FINISH-----------");
        }//public void run(int idx)
    }
}
